//
//  WXLMainViewController.swift
//  WXLWeoBo
//
//  Created by 王晓雷 on 16/6/25.
//  Copyright © 2016年 王晓雷. All rights reserved.
//

import UIKit

class WXLMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 自定义tabBar
        let tabBar = WXLTabBar()
        // 设置代理
        tabBar.wxlDelegate = self
        // 通过KVC 给只读属性赋值
        setValue(tabBar, forKey: "tabBar")
        
        super.viewDidLoad()
       addChildViewController(WXLHomeTableViewController(), title: "首ૢ页ૢ", imageName: "tabbar_home")
        addChildViewController(WXLDiscoverTableViewController(), title: "发ૢ现ૢ", imageName: "tabbar_discover")
        addChildViewController(WXLMessageTableViewController(), title: "信ૢ息ૢ", imageName: "tabbar_message_center")
        addChildViewController(WXLProfileTableViewController(), title: "我ૢ", imageName: "tabbar_profile")
        
        
    }

     func addChildViewController(vc: UIViewController,title: String,imageName: String) {
        
        //设ૢ置ૢtitle
        vc.title = title
        //设ૢ置ૢimage
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
    
}
extension WXLMainViewController: WXLTabBarDelegate{
    func composeButtonClick() {
        print("弹出控制器")
    }
}

